Skip to content

feat: Implement 3D flight animation methods using Vedo (Issue #523)#909

Merged
Gui-FernandesBR merged 1 commit into
RocketPy-Team:developfrom
GuilhermeAsura:feature/add_animation_methods
Jun 27, 2026
Merged

feat: Implement 3D flight animation methods using Vedo (Issue #523)#909
Gui-FernandesBR merged 1 commit into
RocketPy-Team:developfrom
GuilhermeAsura:feature/add_animation_methods

Conversation

@GuilhermeAsura

Copy link
Copy Markdown

Pull request type

  • Code changes (bugfix, features)
  • Code maintenance (refactoring, formatting, tests)

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md has been updated (if relevant)

Current behavior

Currently, the Flight class lacks built-in methods for 3D visualization of the simulation results. Users wishing to visualize the rocket's trajectory or attitude must export data and use external tools or write custom scripts. This addresses Issue #523.

New behavior

This PR integrates 3D visualization capabilities directly into the Flight class using the vedo library.

Key Changes:

  1. New Methods in Flight:
    • animate_trajectory(file_name, start, stop, time_step): Visualizes the 6-DOF translation of the rocket relative to the ground.
    • animate_rotate(file_name, start, stop, time_step): Visualizes the specific attitude (rotation) of the rocket during flight.
  2. Optional Dependency:
    • Added vedo as an optional dependency in pyproject.toml under the [animation] key.
    • Users can install it via pip install rocketpy[animation].
  3. Error Handling:
    • Both methods check for the existence of vedo and raise a descriptive ImportError with installation instructions if it is missing.
  4. Refactoring:
    • Ported original logic from the legacy animate_flight branch to match the current Flight class structure (e.g., removing deprecated postProcess calls).

Breaking change

  • No

Additional information

Acknowledgements

This feature was originally developed by Patrick Sampaio in the animate_flight branch. This PR adapts that work to the modern develop branch structure and newer RocketPy architecture.

Verification

A modular verification suite was added in tests/animation_verification/ to generate a dummy 3D model and test the invocation of the animation methods.

trajectory_animation

@GuilhermeAsura GuilhermeAsura requested a review from a team as a code owner December 6, 2025 03:50
@Gui-FernandesBR

Copy link
Copy Markdown
Member

@GuilhermeAsura could you please fix tests and linters on CI?

@GuilhermeAsura

Copy link
Copy Markdown
Author

@GuilhermeAsura could you please fix tests and linters on CI?

I'm on it!

@Gui-FernandesBR Gui-FernandesBR force-pushed the feature/add_animation_methods branch from 4a29817 to aebdf6a Compare December 9, 2025 00:25
Comment thread rocketpy/simulation/flight.py
Comment thread tests/animation_verification/rocket_stl.py Outdated

@Gui-FernandesBR Gui-FernandesBR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code coverall looks good, but needs refactor.

We can still add it to the next release (this month)

@Gui-FernandesBR Gui-FernandesBR linked an issue Dec 9, 2025 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 7 changed files in this pull request and generated 21 comments.

Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
@Gui-FernandesBR

Copy link
Copy Markdown
Member

Before we merge this PR, some points should be addressed:

  • all plotting methods should be defined withing the plots/ folder
  • the vedo package should be added as an optional requirement
  • Unit tests are needed
  • CHANGELOG.md should be updated
  • The code should be formatted and linted
  • All the comments raised by reviewers should be addressed

@codecov

codecov Bot commented Mar 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.93103% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.24%. Comparing base (9cf3dd4) to head (a39ec8f).
⚠️ Report is 89 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/plots/flight_plots.py 87.93% 14 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #909      +/-   ##
===========================================
+ Coverage    80.27%   81.24%   +0.96%     
===========================================
  Files          104      113       +9     
  Lines        12769    14814    +2045     
===========================================
+ Hits         10250    12035    +1785     
- Misses        2519     2779     +260     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Gui-FernandesBR

Copy link
Copy Markdown
Member

I am working on this one locally

@Gui-FernandesBR

Copy link
Copy Markdown
Member

@YuroCastroDev we would love to hear feedbacks from this feature. Do you think you could help us?

@Gui-FernandesBR Gui-FernandesBR force-pushed the feature/add_animation_methods branch from ab5ef3d to 292eadf Compare June 19, 2026 04:23
Implement 3D visualization of flight results in the plots layer using the
optional `vedo` library, addressing issue RocketPy-Team#523:

- `animate_trajectory`: 6-DOF translation of the rocket relative to ground.
- `animate_rotate`: rocket attitude (rotation) evolution during flight.

`vedo` is added as an optional dependency under the `[animation]` extra
(`pip install rocketpy[animation]`); both methods raise a descriptive
ImportError with install instructions when it is missing. A bundled
`default_rocket.stl` asset and unit tests for the animation methods are
included, along with user docs (flight, installation) and a colab cell.

Originally developed by Patrick Sampaio in the legacy `animate_flight`
branch and adapted to the current Flight architecture.

Co-Authored-By: GuilhermeAsura <gmslazzarini@gmail.com>
Co-Authored-By: Gui-FernandesBR <guilherme_fernandes@usp.br>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Gui-FernandesBR Gui-FernandesBR force-pushed the feature/add_animation_methods branch from 292eadf to a39ec8f Compare June 27, 2026 12:54
@Gui-FernandesBR Gui-FernandesBR merged commit 8035949 into RocketPy-Team:develop Jun 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: adds an 3D animation of flight trajectory

3 participants